package com.fyzk.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import com.fyzk.activity.lottery.shuzicai.BallInfo;
import com.fyzk.activity.lottery.shuzicai.SelectBallView;
import com.tyjc.lottery.R;

import java.util.List;

/**
 * 选球模块
 * @author mm
 *
 */
public class SelectBallLayout extends BaseLinear{
	
	private TextView mTxt_title;
	private TextView mTxt_remind;
	private SelectBallView mVi_selectBall;
	
	/* 选球数  */
	private int select_count;
	/* 最大选球数  */
	private int select_max = 100;

	/* 小球总个数  */
	private int count;
	private Bitmap bitmap_ballnormal;
	private Bitmap bitmap_ballsel;
	private int h_show_count;
	private int color_balltxt_nor;
	private int color_balltxt_sel;
	private int ballType;
	
	private String res_title;
	private String res_remind;
	
	
	public SelectBallLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public SelectBallLayout(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}
	
	@Override
	protected void init(AttributeSet attrs) {
		// TODO Auto-generated method stub
		View.inflate(context, R.layout.layout_select_ball, this);
		if(isInEditMode()){
			return;
		}
		mTxt_title = (TextView)findViewById(R.id.layout_selectball_title);
		mTxt_remind = (TextView)findViewById(R.id.layout_selectball_remind);
		mVi_selectBall = (SelectBallView)findViewById(R.id.layout_selectball_ballview);
		TypedArray typedArray = context.obtainStyledAttributes(attrs,
				R.styleable.SelectBallView);
		int N = typedArray.getIndexCount();
		int resourceId;
		for (int i = 0; i < N; i++) {
			int attr = typedArray.getIndex(i);
			switch (attr) {
			case R.styleable.SelectBallView_ball_nor:
				resourceId = typedArray.getResourceId(
						R.styleable.SelectBallView_ball_nor, 0);
				bitmap_ballnormal = BitmapFactory.decodeResource(
						context.getResources(), resourceId);
				break;
			case R.styleable.SelectBallView_ball_sel:
				resourceId = typedArray.getResourceId(
						R.styleable.SelectBallView_ball_sel, 0);
				bitmap_ballsel = BitmapFactory.decodeResource(
						context.getResources(), resourceId);
				break;
			case R.styleable.SelectBallView_lineNums:
				resourceId = typedArray.getInt(
						R.styleable.SelectBallView_lineNums, 8);
				h_show_count = resourceId;
				break;
			case R.styleable.SelectBallView_txtcolor_nor:
				resourceId = typedArray.getColor(
						R.styleable.SelectBallView_txtcolor_nor, 0);
				color_balltxt_nor = resourceId;
				break;
			case R.styleable.SelectBallView_txtcolor_sel:
				resourceId = typedArray.getColor(
						R.styleable.SelectBallView_txtcolor_sel, 0);
				color_balltxt_sel = resourceId;
				break;
			case R.styleable.SelectBallView_ballType:
				resourceId = typedArray.getColor(
						R.styleable.SelectBallView_ballType, 0);
				ballType = resourceId;
				break;
			case R.styleable.SelectBallView_remind:
				res_remind = typedArray.getString(
						R.styleable.SelectBallView_remind);
				break;
			case R.styleable.SelectBallView_ball_title:
				res_title = typedArray.getString(
						R.styleable.SelectBallView_ball_title);
				break;
			}
			mTxt_title.setText(res_title);
			mTxt_remind.setText(res_remind);
//			mVi_selectBall 
		}
	}
	
	
	
	/**
	 * 设置选球区域的标题
	 * @param resid
	 */
	public void setTitle(int resid){
		mTxt_title.setText(resid);
	}
	/**
	 * 设置选球区域选球的提示语
	 * @param resid
	 */
	public void setSelectRemind(int resid){
		mTxt_remind.setText(resid);
	}
	/**
	 * 设置选球区域选球的信息
	 * @param list_qiu
	 */
	public void setBallInfoList(List<BallInfo> list_qiu) {
		mVi_selectBall.setBallInfoList(list_qiu);
	}
	
	

}
